<HTML>
<HEAD>
<TITLE> STATES User's Guide </TITLE>
</HEAD>

<BODY style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">

<A NAME="top"></A>

<TABLE STYLE="text-align: left; margin-left: auto; margin-right: auto; width: 800px;" BORDER="0" CELLPADDING="5" CELLSPACING="2">
<TBODY>
<TR>
  <TD STYLE="background-color: rgb(153, 153, 153); vertical-align: middle; text-align: center;">
  <DIV ALIGN="right">
    <SMALL><SMALL><A HREF="index.html">Index Page</A></SMALL></SMALL>
  </DIV>
  <B>STATES User's Guide</B> </TD>
</TR>
<TR>
  <TD STYLE="vertical-align: top;">

<H2> Table of Contents
</H2>

<PRE>
   <A HREF="#STATES User's Guide">STATES User's Guide</A>
      <A HREF="#Abstract">Abstract</A>
      <A HREF="#Summary">Summary</A>

</PRE>

<HR SIZE=3 NOSHADE>

<BR><BR>
<A NAME="STATES User's Guide"></A>
<p align="right"><a href="#top"><small>Top</small></a></p>
<H1> STATES User's Guide
</H1><HR SIZE=3 NOSHADE><P><BR><BR><BR>
   Last revised on 2002 DEC 13 by E. D. Wright.
<P>
 
<BR><BR>
<A NAME="Abstract"></A>
<p align="right"><a href="#top"><small>Top</small></a></p>
<H2> Abstract
</H2><HR ALIGN="LEFT" WIDTH=50% ><P><BR><BR>
   STATES is a cookbook program that demonstrates how to use Toolkit
   routines to obtain state vectors.
<P>
 
<BR><BR>
<A NAME="Summary"></A>
<p align="right"><a href="#top"><small>Top</small></a></p>
<H2> Summary
</H2><HR ALIGN="LEFT" WIDTH=50% ><P><BR><BR>
   The STATES `cookbook' program illustrates the use of SPICE SPK files and
   CSPICE subroutines. The program performs look-ups of state vectors from
   an SPK file.
<P>
 
   STATES demonstrates the use of the following high-level subroutines:
<P>
 
<DL><DT>
<B>
 <a href="../cspice/furnsh_c.html">furnsh_c</a>
</B><BR><BR>
<DD>
 Load SPICE kernels<BR>
</DL>
<DL><DT>
<B>
 <a href="../cspice/spkezr_c.html">spkezr_c</a>
</B><BR><BR>
<DD>
 SPK, easy reader<BR>
</DL>
<DL><DT>
<B>
 <a href="../cspice/str2et_c.html">str2et_c</a>
</B><BR><BR>
<DD>
 Convert time string to ephemeris time<BR>
</DL>
<DL><DT>
<B>
 <a href="../cspice/et2utc_c.html">et2utc_c</a>
</B><BR><BR>
<DD>
 Convert ephemeris time to UTC string<BR>
</DL>
   Examine the STATES source code for usage examples of these routines.
   Also, refer to the SPK Required Reading (<a href="../req/spk.html">spk.req</a>) and the module headers
   for these routines to obtain additional information.
<P>
 
   To run STATES, you need a binary SPK ephemeris file and knowledge of the
   bodies and corresponding time intervals contained in that file. The
   utility program named BRIEF summarizes a binary SPK file; NAIF IDs
   Required Reading (<a href="../req/naif_ids.html">naif_ids.req</a>) lists body names and codes. In addition
   to an SPK file, you also require access to a leapseconds kernel (LSK).
<P>
 
   Below, find an example STATES session that calculates the state of the
   Moon relative to the Earth at various times during the first day of
   January, 1990.
<P>
 
   STATES prompts you for the integer codes or string names of target and
   observer bodies, a reference frame for the state evaluation, the
   aberration correction to use with the evaluation, the end-points
   (expressed in UTC) of a time interval, and the number of evaluations
   (state look-ups) to perform over the assigned time interval. Given this
   input, STATES displays to the terminal the state, (position and
   velocity) at each evaluation of the target body as seen from the
   observer in the declared reference frame adjusted for the specified
   aberration correction.
<P>
 
   Please note: FORTRAN and C versions of the program can output numerical
   values in slightly different formats.
<P>
 
   It is assumed the kernel files used by STATES exist in the current
   directory (i.e. the directory from which your execute STATES). This
   particular session was run on an Intel box using the LINUX operating
   system.
<P>
 
   First, create the binary SPK kernel "cook_01.bsp" by running the CSPICE
   Toolkit TOBIN application on the transfer format file "cook_01.tsp"
   located in the CSPICE data directory. The program also requires a
   leapseconds kernel to run; an example leapseconds kernel, 'cook_01.tls'
   exists within the same directory. Now, execute STATES:
<P>
 
<PRE>
 
                   Welcome to STATES
 
   This program demonstrates the use of NAIF S- and P-
   Kernel (SPK) files and subroutines by computing the
   state of a target body as seen from an observing
   body at a number of epochs within a given time
   interval.
 
 
   Enter the name of a leapseconds kernel file: cook_01.tls
 
   Enter the name of a binary SPK ephemeris file: cook_01.bsp
 
   Enter the name of the observing body: earth
 
   Enter the name of a target body: moon
 
   Enter the number of states to be calculated: 5
 
   Enter the beginning UTC time: 1 jan 1990
 
   Enter the ending UTC time: 2 jan 1990
 
   Enter the inertial reference frame (eg:J2000): j2000
 
   Type of correction                              Type of state
   -------------------------------------------------------------
   'LT+S'    Light-time and stellar aberration    Apparent state
   'LT'      Light-time only                      True state
   'NONE'    No correction                        Geometric state
 
   Enter LT+S, LT, or NONE: LT+S
 
   Working ... Please wait
 
   For time 1 of 5, the state of:
   Body            : moon
   Relative to body: earth
   In Frame        : j2000
   At UTC time     : 1990 JAN 01 00:00:00
 
                    Position (km)              Velocity (km/s)
               -----------------------     -----------------------
             X:  3.1817356914228073e+05         5.3394535681481514e-01
             Y: -1.9411657590890554e+05         7.7051535844816144e-01
             Z: -7.7812550159748964e+04         4.3386380567914284e-01
     MAGNITUDE:  3.8074986290962604e+05      1.0329711339369498e+00
 
 
   Continue? (Enter Y or N): Y
   For time 2 of 5, the state of:
   Body            : moon
   Relative to body: earth
   In Frame        : j2000
   At UTC time     : 1990 JAN 01 06:00:00
 
                    Position (km)              Velocity (km/s)
               -----------------------     -----------------------
             X:  3.2915688826278772e+05         4.8249639220368934e-01
             Y: -1.7715581503624297e+05         7.9947042534779911e-01
             Z: -6.8315337774688582e+04         4.4523496484754310e-01
     MAGNITUDE:  3.7999398056714883e+05      1.0344998324882222e+00
 
 
   Continue? (Enter Y or N): Y
   For time 3 of 5, the state of:
   Body            : moon
   Relative to body: earth
   In Frame        : j2000
   At UTC time     : 1990 JAN 01 12:00:00
 
                    Position (km)              Velocity (km/s)
               -----------------------     -----------------------
             X:  3.3900715098782443e+05         4.2906743233110589e-01
             Y: -1.5959674510107530e+05         8.2587395364385063e-01
             Z: -5.8588018067307996e+04         4.5515161940699311e-01
     MAGNITUDE:  3.7924863259976875e+05      1.0360162380210756e+00
 
 
   Continue? (Enter Y or N): Y
   For time 4 of 5, the state of:
   Body            : moon
   Relative to body: earth
   In Frame        : j2000
   At UTC time     : 1990 JAN 01 18:00:00
 
                    Position (km)              Velocity (km/s)
               -----------------------     -----------------------
             X:  3.4768335621335648e+05         3.7382616249951184e-01
             Y: -1.4149583716010855e+05         8.4960221441502703e-01
             Z: -4.8662586928824239e+04         4.6356151096043718e-01
     MAGNITUDE:  3.7851398321334057e+05      1.0375255162895767e+00
 
 
   Continue? (Enter Y or N): Y
   For time 5 of 5, the state of:
   Body            : moon
   Relative to body: earth
   In Frame        : j2000
   At UTC time     : 1990 JAN 02 00:00:00
 
                    Position (km)              Velocity (km/s)
               -----------------------     -----------------------
             X:  3.5514823394910217e+05         3.1695019646037181e-01
             Y: -1.2291215332598702e+05         8.7053938526942165e-01
             Z: -3.8572119287635753e+04         4.7041716136973366e-01
     MAGNITUDE:  3.7779025119599997e+05      1.0390325086601906e+00
 
 
</PRE>

</TD>
</TR>
</TBODY>
</TABLE>

</BODY>

</HTML>
